home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 February / PCWFEB08.iso / Software / Freeware / Miro 1.0 / Miro_Installer.exe / resources / templates / channel-folder < prev    next >
Encoding:
Text File  |  2007-11-12  |  5.1 KB  |  169 lines

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2.  
  3. <html xmlns="http://www.w3.org/1999/xhtml"
  4.       eventCookie="@@@eventCookie@@@" dtvPlatform="@@@dtvPlatform@@@">
  5.  
  6. <head>
  7.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8.  
  9.     <link href="resource:css/main.css" rel="stylesheet" type="text/css" />
  10.     <t:include filename="dynamic.js" />
  11.     <script type="text/javascript" src="resource:templates/osxdnd.js" />
  12.     <t:execOnLoad><![CDATA[
  13.  
  14. folder = views.channelFolders.getObjectByID(int(kargs['id']))
  15. filters.switchNewItemsChannel(folder)
  16. sorts.switchUnwatchedFirstChannel(folder)
  17.  
  18. def showDownloadsFilter(x):
  19.     return showDownloads
  20.  
  21. def showWatchableFilter(x):
  22.     return showWatchableItems
  23.  
  24. def showNewFilter(x):
  25.     isNew = filters.newItems(x)
  26.     # need to make call newItems() so that the filter remembers if the item
  27.     # was flagged as new or not.
  28.     return showNewItems and (allItemsMode or isNew)
  29.  
  30. def updateSearchString(newSearch):
  31.     global searchTerm
  32.     if len(newSearch) == 0:
  33.         searchTerm = None
  34.     else:
  35.         searchTerm = newSearch
  36.     allItems.recomputeFilters()
  37.  
  38. def toggleDownloadsView(handle):
  39.     global showDownloads
  40.     showDownloads = not showDownloads
  41.     allDownloadingItems.recomputeFilter(downloadingItems)
  42.     handle.forceUpdate()
  43.  
  44. def toggleWatchableView(handle):
  45.     global showWatchableItems
  46.     showWatchableItems = not showWatchableItems
  47.     allWatchableItems.recomputeFilter(watchableItems)
  48.     handle.forceUpdate()
  49.  
  50. def toggleNewItemsView(handle):
  51.     global showNewItems
  52.     showNewItems = not showNewItems
  53.     matchingItems.recomputeFilter(newItems)
  54.     handle.forceUpdate()
  55.  
  56. def toggleAllItemsMode(handle):
  57.     print "Toggling all items"
  58.     global allItemsMode
  59.     allItemsMode = not allItemsMode
  60.     matchingItems.recomputeFilter(newItems)
  61.     handle.forceUpdate()
  62.  
  63. def setSortBy(by, which, handle):
  64.     if which == 'main':
  65.       folder.itemSort.setSortBy(by)
  66.       matchingItems.recomputeSort(newItems)
  67.     elif which == 'downloading':
  68.       feed.itemSortDownloading.setSortBy(by)
  69.       allDownloadingItems.recomputeSort(downloadingItems)
  70.     else:
  71.       folder.itemSortWatchable.setSortBy(by)
  72.       allWatchableItems.recomputeSort(watchableItems)
  73.     handle.forceUpdate()
  74.  
  75. allFeeds = views.feeds.filterWithIndex(indexes.byFolder, folder)
  76.  
  77. global searchTerm, showDownloads, showWatchableItems, showNewItems, allItemsMode
  78. searchTerm = None
  79.  
  80. # The main section
  81. allItemsMode = False
  82.  
  83. # Initial states of views in this template
  84. showDownloads = False
  85. showNewItems = True
  86. showWatchableItems = True
  87.  
  88. allItems = views.items.filterWithIndex(indexes.itemsByChannelFolder, folder)
  89. notDeleted = allItems.filter(filters.notDeleted)
  90. matchingItems = notDeleted.filter(lambda x: filters.matchingItems(x, searchTerm))
  91. newItems = matchingItems.filter(showNewFilter, sortFunc=folder.itemSort.sort, resort=True)
  92.  
  93. allDownloadingItems = matchingItems.filter(filters.downloadingOrPausedItems)
  94. downloadingItems = allDownloadingItems.filter(showDownloadsFilter,sortFunc=folder.itemSortDownloading.sort,resort=True)
  95. allWatchableItems = matchingItems.filter(filters.watchableItems)
  96. watchableItems = allWatchableItems.filter(showWatchableFilter,sortFunc=folder.itemSortWatchable.sort, resort=True)
  97.  
  98. thisFolderView = views.channelFolders.filter(lambda x: x is folder)
  99. childrenView = views.feeds.filterWithIndex(indexes.byFolder, folder)
  100.  
  101. # Make the channel-content template happy
  102. thisFeedView = thisFolderView
  103. feed = None
  104. itemSort = folder.itemSort
  105. itemSortDownloading = folder.itemSortDownloading
  106. itemSortWatchable = folder.itemSortWatchable
  107.  
  108. def allItemsHaveState(view, state):
  109.     for item in view:
  110.         if item.getState() != state:
  111.             return False
  112.     return True
  113. def allItemsPaused(view):
  114.     return allItemsHaveState(view, 'paused')
  115. def allItemsDownloading(view):
  116.     return allItemsHaveState(view, 'downloading')
  117.  
  118. showNewItems = (len(watchableItems) == 0) or len(newItems) > 0
  119.  
  120. if len(newItems) == 0:
  121.     allItemsMode = True
  122.     matchingItems.recomputeFilter(newItems)
  123.  
  124. for feed in allFeeds:
  125.     feed.updateIcons()
  126.  
  127. isFolder = True
  128. ]]>
  129.     </t:execOnLoad>
  130.     <t:execOnUnload><![CDATA[
  131. matchingItems.unlink()
  132. thisFolderView.unlink()
  133. notDeleted.unlink()
  134. allItems.unlink()
  135. for feed in allFeeds:
  136.     if feed.idExists():
  137.         feed.markAsViewed()
  138. ]]>
  139.     </t:execOnUnload>
  140. </head>
  141.  
  142. <body dragdesttype="channel"
  143.     dragdestdata="channelfolder-***folder.getID()***"
  144.     drageffectchannel="move"
  145.     onkeydown="sendKeyToSearchBox(event);">
  146. <div id="main-titlebar">
  147.     <img id="main-icon" src="resource:images/folder-icon.png" alt="" />
  148.     <div t:updateForView="thisFolderView">
  149.         <h1 id="main-title" t:replace="folder.getTitle()" />
  150.     </div>
  151. </div>
  152. <div id="main-container">
  153.     <t:includeTemplate filename="channel-content" />
  154. </div>
  155. <div t:updateForView="childrenView">
  156. <div t:showIf="childrenView.len() == 0">
  157.     <div class="channel-blank">
  158.     <div class="channel-message" i18n:translate="">
  159.         Empty Channel Folder
  160.     </div>
  161.     <div class="channel-message small" i18n:translate="">
  162.         Drag channels to this folder to add them.
  163.     </div>
  164.     </div>
  165. </div>
  166. </div>
  167. </body>
  168. </html>
  169.